<?php
include ('header.php');
if ($admin==1) {
if (count($_POST)>1) {
$pnewspage=$_POST['newspage'];
$puserpage=$_POST['userpage'];
$pmesspage=$_POST['messpage'];
$pprepnewsmain=$_POST['prepnewsmain'];
$pnewsmain=$_POST['newsmain'];
$ptemplates=$_POST['templates'];
$ppatch_avatar=$_POST['patch_avatar'];
$pmailname=$_POST['mailname'];
$padminmail=$_POST['adminmail'];
mysql_query ("UPDATE `setting` SET
`newspage` = '$pnewspage',
`userpage` = '$puserpage',
`messpage` = '$pmesspage',
`newsmain` = '$pnewsmain',
`templates` = '$ptemplates',
`patch_avatar` = '$ppatch_avatar',
`mailname` = '$pmailname',
`adminmail` = '$padminmail'
WHERE `id`=1;") or die(mysql_error());
echo '<h3>Настройки сохранены.</h3>';}
$setres = mysql_query("SELECT * FROM setting") or die(mysql_error()); //извлекаем из базы все данные о пользователе
$setting = mysql_fetch_array($setres);
$newspage=$setting['newspage'];
$userpage=$setting['userpage'];
$messpage=$setting['messpage'];
$prepnewsmain=$setting['prepnewsmain'];
$newsmain=$setting['newsmain'];
$templates=$setting['templates'];
$patch_avatar=$setting['patch_avatar'];
$mailname=$setting['mailname'];
$adminmail=$setting['adminmail'];
?>
<hr />
<form action="#" method="post" name="setting">
<fieldset>
    <hr />
    <strong>Основные настройки:</strong><br />
    <dl>
		<dt class="dtreg">Шаблон:</dt>
		<dd class="ddreg"><input name="templates" type="text" size="15" maxlength="15" value="<?php echo $templates; ?>" /></dd>
	</dl>
    <dl>
		<dt class="dtreg">Папка с аватарами:</dt>
		<dd class="ddreg"><input name="patch_avatar" type="text" size="15" maxlength="15" value="<?php echo $patch_avatar; ?>" /> "\" в конце обязательно.</dd>
	</dl>
    <dl>
		<dt class="dtreg">Имя e-mail:</dt>
		<dd class="ddreg"><input name="mailname" type="text" size="100" maxlength="100" value="<?php echo $mailname; ?>" /></dd>
	</dl>
    <dl>
		<dt class="dtreg">E-mail исходящих сообщений:</dt>
		<dd class="ddreg"><input name="adminmail" type="text" size="100" maxlength="100" value="<?php echo $adminmail; ?>" /></dd>
	</dl>
    <hr />
<strong>На странице:</strong><br />
	<dl>
		<dt class="dtreg">Новостей:</dt>
		<dd class="ddreg"><input name="newspage" type="text" size="3" maxlength="3" value="<?php echo $newspage; ?>" /></dd>
	</dl>
    <dl>
		<dt class="dtreg">Пользователей:</dt>
		<dd class="ddreg"><input name="userpage" type="text" size="3" maxlength="3" value="<?php echo $userpage; ?>" /></dd>
	</dl>
    <dl>
		<dt class="dtreg">Сообщений:</dt>
		<dd class="ddreg"><input name="messpage" type="text" size="3" maxlength="3" value="<?php echo $messpage; ?>" /></dd>
	</dl>
    <dl>
		<dt class="dtreg">Новостей на главной:</dt>
		<dd class="ddreg"><input name="newsmain" type="text" size="3" maxlength="3" value="<?php echo $newsmain; ?>" /></dd>
	</dl>
    <dl>
		<dt class="dtreg">Преподовательских новостей на главной:</dt>
		<dd class="ddreg"><input name="prepnewsmain" type="text" size="3" maxlength="3" value="<?php echo $prepnewsmain; ?>" /></dd>
	</dl>
<input name="setting" type="submit" value="Сохранить" />
</fieldset>
</form>
	<dl>
		<dt class="dtreg"></dt>
		<dd class="ddreg"></dd>
	</dl>
<hr />
<?php
	include ('footer.php');
} else {echo 'Недостаточно прав';};
?>